`
https://leetcode.cn/problems/maximum-number-of-operations-to-move-ones-to-the-end/
`

/**
 * @param {string} s
 * @return {number}
 */
var maxOperations = function (s) {
  const n = s.length
  let res = 0
  let count = 0
  let curCount = 0

  for (let i = 0; i < n; i++) {
    if (s[i] === '1') {
      curCount++
    } else if (i > 0 && s[i - 1] === '1') {
      // 当前 1 和之前的 1 都可以往前移动一次
      res += count + curCount
      count += curCount
      curCount = 0
    }
  }

  return res
};